const KoaRouter = require('koa-router');
const router = new KoaRouter({ prefix: '/auth' });
const controller = require('../controllers/authController');
const {
  login, register, OriginalPassValidity,
  newPassLegitimacy, authenticateToken
} = require('../middleware/validation');

router.post('/login', login, controller.login);
router.post('/register', register, controller.register);
router.post('/changePassword/:id',
  authenticateToken,
  OriginalPassValidity,
  newPassLegitimacy,
  controller.changePassword
);
router.post('/refresh', authenticateToken, controller.refresh);
router.post('/logout', authenticateToken, controller.logout);

module.exports = router;